package com.neuedu.nep.controller;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ControllerManager {

    private static final Map<String, Object> controllers = new ConcurrentHashMap<>();

    // 注册控制器
    public static void registerController(String sceneId, Object controller) {
        System.out.println("Registering controller " + controller);

        controllers.put(sceneId, controller);
    }

    // 获取控制器
    @SuppressWarnings("unchecked")
    public static <T> T getController(String sceneId) {
        return (T) controllers.get(sceneId);
    }

    // 销毁控制器
    public static void disposeController(String sceneId) {
        if (controllers.containsKey(sceneId)) {
            // 执行清理操作（可选）
            controllers.remove(sceneId);
        }
    }
}